import { VuexModule, Module, getModule, Mutation } from 'vuex-module-decorators'
// import api from '@/core/api'
import store from '@/store'

export interface ICurrentMenu {
  key: string;
}

export interface IAppState {
}
@Module({
  dynamic: true,
  namespaced: true,
  store,
  name: 'app',
  preserveState: sessionStorage.getItem('vuex') !== null
})
class App extends VuexModule implements IAppState {
  public currentMenu: Partial<ICurrentMenu> = {};

  get isLargeScreen() {
    return window.screen.width > 1920
  }

  @Mutation
  public SET_CURRENT_MENU(menu: Partial<ICurrentMenu>) {
    // @ts-ignore
    const id = menu.domEvent.target.dataset.id
    this.currentMenu = Object.assign(this.currentMenu, {
      key: menu.key,
      id
    });
  }
}

export const appModule = getModule(App)

export default App
